1   package com.iluwatar;
2   
3   /**
4    * This is a single service implementation of a sample service. This is the actual
5    * service that will process the request. The reference for this service is to
6    * be looked upon in the JNDI server that can be set in the web.xml deployment descriptor
7    *
8    * @author saifasif
9    */
10  public class ServiceImpl implements Service {
11  
12      private final String serviceName;
13      private final int id;
14  
15      public ServiceImpl(String serviceName) {
16          // set the service name
17          this.serviceName = serviceName;
18  
19          // Generate a random id to this service object
20          this.id = (int) Math.floor(Math.random() * 1000) + 1;
21      }
22  
23      @Override
24      public String getName() {
25          return serviceName;
26      }
27  
28      @Override
29      public int getId() {
30          return id;
31      }
32  
33      @Override
34      public void execute() {
35          System.out.println("Service " + getName() + " is now executing with id " + getId());
36      }
37  }